<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	May 22, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/candidates/tmpl/buildcv.php
 ^ 
 * Description: candidate action
 ^ 
 * History:		NONE	
 ^ 
 */
  defined('_JEXEC') or die('Restricted access');
  global $mainframe;
  $document =& JFactory::getDocument();

  /* $document->addScript( 'components/com_wrecruit/js/jquery-1.7.2.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery-ui.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery.uniform.js' );
  $document->addScript( 'components/com_wrecruit/js/scripts.js' );*/
  $document->addScript( 'components/com_wrecruit/js/popup.js' );
  $document->addStyleSheet('components/com_wrecruit/css/popup.css');
  $document->addStyleSheet('components/com_wrecruit/css/chosen/chosen.css');
  $document->addStyleSheet('components/com_wrecruit/css/date.css');
  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
  $user	=& JFactory::getUser();
  if(isset($user->id) && $user->id == 0 || $user->id == ''){
	   $app =& JFactory::getApplication(); 
	   $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );
	  return;
  }else{
  	$candidateObj = $candidate->getAllCandidatesInfor($user->id);
	if( !$candidateObj ){
		$app =& JFactory::getApplication(); 
       //add a message to the message queue
        $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );

		return;
	}
	
   }
   $com_base = "components/com_wrecruit/";
   
  //Registric resume access
  if(!$candidate->checkAuticationResume($user->id,JRequest::getVar('id'))){
	  $session = &JFactory::getSession();
	  $msg = $session->get('job_msg');
	  echo $msg;
	  return;
  }
    ?>
<div class="box-list filter-job">
					<div class="head-title">
						<h2>Build CV</h2>
					</div>
					<div class="box-cv">
                    	<h3 class="sub-title">Basic Info</h3>
                        <div id="cv-1" class="default-box">
                        	<div id="pic-pro">
							<?php
							  if(file_exists(JPATH_SITE.DS.'wrecruitdata'.DS.'photo'.DS.$candidateObj->photo)){
							  ?>
								<img height="100" width="100" src="<?php echo JURI::base();?>/wrecruitdata/photo/<?php echo $candidateObj->photo; ?>" 
						alt="<?php echo $candidateObj->firstname." ".$candidateObj->lastname;?>">
							<? } ?>
                            </div>
                            <p><strong><?php echo $candidateObj->firstname." ".$candidateObj->lastname;?></strong></p>
                            <p><strong class="txt-b">Gender: <span style="color:#FF0000; float:right;">*</span></strong>
                             <?php echo $candidateObj->gender;?>
                            </p>
                            <p><strong class="txt-b">Birthday: <span style="color:#FF0000; float:right;">*</span></strong> 
                            <?php echo $candidateObj->date['month'];?>
							<?php echo $candidateObj->date['day'];?>
                            <?php echo $candidateObj->date['year'];?>
                        </div>
                    </div>
                
                 <div id="cv-2">
                       <h3 class="sub-title">Contact Info</h3>
                       <div class="divwrapp">
                        <p><strong class="txt-b">Email: </strong><label><?php echo $candidateObj->EMAIL;?></label></p>
                        <p><strong class="txt-b">Tel: </strong><label><?php echo $candidateObj->phone;?></label></p>
                        <p><strong class="txt-b">Address: </strong><label> <?php echo trim($candidateObj->address);?></label></p>
                       
                       </div>
                 </div>
                 <form action="index.php" method="post">
                     <div class="cv-3 job-option-block">
                     	<div class="job-option-block-header active">
                       		<h3 class="sub-title">Career objective</h3>
                            <a class="ts_expanse" href="#">Expanse</a>
						</div>
                     <div class="job-option-block-content"><!--start content-->
                       <div class="divwrapp">
                            <textarea rows="4" cols="70"  name="careerobjective" id="carrer-text-area" placeholder="Express your career objective here..."><?php echo $candidate->getCareerObjective(JRequest::getVar('id'));?></textarea>
							
                       <div style=" width:90px; height:58px; float:left;">&nbsp;</div><input type="submit"  value="Done"id="done"/>
                       </div>
                        <input type="hidden" value="<?php echo JRequest::getVar('id');?>" name="id">
                        <input type="hidden" value="buildcv" name="layout">
                        <input type="hidden" value="com_wrecruit" name="option">
                        <input type="hidden" value="addCareerObjective" name="task">
                        <input type="hidden" value="candidates" name="view" />
                        <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
                        
                     </div><!--end content-->
                     
                 </div>
                 </form>
                 
                  <!--start-->
                  <div class="cv-3 job-option-block">
                  	<div class="job-option-block-header active">
                       <h3 class="sub-title">Professional experiences</h3>
                       <a class="ts_expanse" href="#">Expanse</a>
					</div>
                    <div class="job-option-block-content"><!--start content-->
                       <div class="divwrapp">
                       		<div class="btn-action">
                                <div class="wrapp-btn">
                                    <span class="btn-left"><span class="btn-right"><input type="submit" id="pro_experience" class="add wpopup btn" value="Add" border="none" /> &nbsp;</span></span>
                               </div>
                             </div>
                                            
                       </div>
					    <?php 
						  	if ( $data = $candidate->getProListByResumeId(JRequest::getVar('id')) ) {
							 $n = count($data);
								 
								 for ( $i = 0; $i < $n; $i++) {
										?>
                                        <div class="divwrapp1" id="pro_experience_parent_form">
										<strong><?php echo $data[$i]->employer_position;?></strong>
										<a href="#" title="" class="cv-delete cv_item_remove" id="cv_remove_pro_<?php echo $data[$i]->id;?>"><img alt="" src="<?php echo $com_base;?>images/delete.gif" width="20" height="20"/></a>
										<a href="#" title="" class="cv-edit cv_item_edite" id="cv_edit_pro_<?php echo $data[$i]->id;?>"><img alt="" src="<?php echo $com_base;?>images/edit.gif" width="20" height="20" style="float:right; margin-right:3px;"/></a>
										<p><strong class="txt-b1"><?php echo $data[$i]->employer;?></strong></p>
										<div><?php echo $data[$i]->employer_address." | ";?> <?php echo $data[$i]->employer_city." | ";?> <?php echo $candidate->getCountryByCode($data[$i]->employer_country);?></div>
										<div>Tel: <?php echo $data[$i]->employer_phone;?></div>
										<div><?php echo date('M-Y',strtotime($data[$i]->employer_from_date));?> - <?php echo date('M-Y',strtotime($data[$i]->employer_to_date));?> (<?php echo round((abs(strtotime($data[$i]->employer_to_date)-strtotime($data[$i]->employer_from_date))/86400)/30)?> months)</div>		
										<p><strong class="txt-b1"><?php echo $data[$i]->employer_resp;?></strong></p>
										</div>
                                        <?php
										
								  }
							}
						  
						  ?>
                       
                       </div><!--end content-->
                       
                 </div>
                 
                  <!--start-->
                 <div class="cv-3 job-option-block">
                 	<div class="job-option-block-header active">
                       <h3 class="sub-title">Education/Training</h3>
                       <a class="ts_expanse" href="#">Expanse</a>
                    </div>
                    <div class="job-option-block-content"><!--start content-->
                       <div class="divwrapp">
                       		<div class="btn-action">
                                <div class="wrapp-btn">
                                    <span class="btn-left"><span class="btn-right"><input type="submit" id="educationform" value="Add" class="add wpopup btn" value="" border="none" /> &nbsp;</span></span>
      							</div>
                            </div>                   
                       </div>
                       <?php 
						  	if ( $data = $candidate->getEducationList(JRequest::getVar('id')) ) {
							 $n = 3;
								 for ( $i = 0; $i <= $n; $i++) {
									    if ($i==0) {
											$sub_fix ='';
										} else {
											$sub_fix =$i;
										}
									 if($data['institute'.$sub_fix] != ''){
										?>
                                    <div class="divwrapp1">
                                    <strong><?php echo $data['institute'.$sub_fix];?></strong>
                                    <a href="#" title="" class="cv-delete cv_item_remove" id="cv_remove_edu<?php if($sub_fix!=''){ echo "_".$sub_fix;};?>" ><img alt="" src="<?php echo $com_base;?>images/delete.gif" width="20" height="20"/></a>
                                    <a href="#" title="" id="cv_edit_edu<?php if( $sub_fix != '' ){ echo "_".$sub_fix;};?>" class="cv-edit cv_item_edite">
                                     <img alt="" src="<?php echo $com_base;?>images/edit.gif" width="20" height="20" style="float:right; margin-right:3px;"/></a>
                                  
                                    <div>Certification title: <strong><?php echo $data['institute'.$sub_fix];?></strong> </div>
                                    <div>
                                     Education level: <strong><?php echo $data['institute'.$sub_fix.'_level'];?></strong>  | 
                                     Year of degree: <strong><?php echo $data['institute'.$sub_fix.'_certificate_name'];?></strong>  |  
                                     Area of study: <strong><?php echo $data['institute'.$sub_fix.'_study_area'];?></strong>  |   
                                     Country: <strong><?php echo $candidate->getCountryByCode($data['institute'.$sub_fix.'_country']); ?></strong>
                                     </div>
                                   
                               </div>     
                           <?php
									 }//End if
								 }
							}
						?>
                  </div><!--end content-->
                       
                 </div>
                 
                  <!--start-->
                 
                 <div class="cv-3 job-option-block">
                 	<div class="job-option-block-header active">
                       <h3 class="sub-title">Skills</h3>
                       <a class="ts_expanse" href="#">Expanse</a>
                    </div>
                    <div class="job-option-block-content"><!--start content-->
                       <div class="divwrapp">
                       		<div class="btn-action">
                                <div class="wrapp-btn">
                                    <span class="btn-left"><span class="btn-right"><input type="submit" id="skill_form" value="Add" class="add wpopup btn" value="" border="none" /> &nbsp;</span></span>
      							</div>
                            </div>                        
                       </div>
                       
                       <div id="divwrapp3">
                       	  <?php 
						  	if ( $data = $candidate->getSkillsListByResumeId(JRequest::getVar('id')) ) {
							 $n = count($data);
								 for ( $i = 0; $i < $n; $i++) {
										?>
                                        <div class="divwrapp2">
                                            <strong><?php echo $data[$i]->skill_name;?></strong>
                                            <a href="#" title="" class="cv-delete cv_item_remove" id="cv_remove_skill_<?php echo $data[$i]->sr_id;?>">
                                              <img alt="" src="<?php echo $com_base;?>images/delete.gif" width="20" height="20"/>
                                            </a>
                                            <a href="#" title="" id="cv_edit_skill_<?php echo $data[$i]->id;?>and<?php echo $data[$i]->sr_id;?>" class="cv-edit cv_item_edite">
                                                <img alt=""  src="<?php echo $com_base;?>images/edit.gif" width="20" height="20"
                                                style="float:right; margin-right:3px; margin-left:10px;"/>
                                            </a>
                                        </div>
                                        <?php
										
								  }
							}
						  
						  ?>
                           
                       		</div><!--end content--> 
                       </div>
                 </div>
                 
                 <!--start-->
                 
                 <div class="cv-3 job-option-block" id="cv-bottom">
                 <div class="job-option-block-header active">
                       <h3 class="sub-title">Reference</h3>
                       <a class="ts_expanse" href="#">Expanse</a>
                  </div>
                  <div class="job-option-block-content"><!--start content-->
                       <div class="divwrapp">
                            <div class="btn-action">
                                <div class="wrapp-btn">
                                    <span class="btn-left"><span class="btn-right"><input type="submit" id="reference" value="Add" class="add wpopup btn" value="" border="none" /> &nbsp;</span></span>
      							</div>
                            </div>                    
                       </div>
                       <?php 
					   
					   	if ( $data = $candidate->getReferenceList(JRequest::getVar('id')) ) {
							 $n = 3;
							 for ( $i = 0; $i <= $n; $i++) {
								 	$subfix = $i;
									if ( $i == 0 ) {
										$subfix = '';
									} 
								  if ( $data['reference'.$subfix.'_name'] != '') { 
									  $ref_base_url = "index.php?option=com_wrecruit&c=wrecruit&view=candidates&tas=deletereference&layout=buildcv&Itemid=".JRequest::getVar('Itemid')."&id=".JRequest::getVar('id')."&part=".$data['reference'.$subfix];
								  ?>
											
									    <div class="divwrapp1" id="wrapper_<?php echo $data['reference'.$subfix]; ?>">
                                        <strong>Reference name: <?php echo $data['reference'.$subfix]; ?></strong>
                                        <a href="#" title="" class="cv-delete cv_item_remove" id="cv_remove_reference<?php if($subfix!=''){echo "_".$subfix;} ?>">
                                        <img alt="" src="<?php echo $com_base;?>images/delete.gif" width="20" height="20"/></a>
                                        <a href="http://www.google.com" id="cv_edit_reference<?php if($subfix!=''){echo "_".$subfix;} ?>" title="" class="cv-edit cv_item_edite">
                                        <img alt="" src="<?php echo $com_base;?>images/edit.gif" width="20" height="20" style="float:right; margin-right:3px;"/></a>
                                       
                                        <div>
                                         Relationship: <strong><?php echo $data['reference'.$subfix.'_relation']; ?></strong>  | 
                                         Year of knowing: <strong><?php echo $data['reference'.$subfix.'_years']; ?></strong>   | 
                                         Phone number: <strong><?php echo $data['reference'.$subfix.'_phone']; ?></strong></div> 
                                        <div>Address:  <strong><?php echo $data['reference'.$subfix.'_address']; ?> </strong> | 
                                         City : <strong><?php echo $data['reference'.$subfix.'_city']; ?></strong>   |  
                                        Country: <strong><?php echo $candidate->getCountryByCode($data['reference'.$subfix.'_country']); ?></strong></div>
                                        
                                   </div>
							      <?php }
							 }
							
						}
					   ?>
                     
                     </div><!--end content-->
                 </div>
                 
                
                 <!--end reference-->
                 
				</div>		
                
	 <!--popup content-->
        <div id="popupContainer" class="hidden" style="text-align:left;">
            <a id="close" class="hidden" title="close popup"></a>   
            <center>
            <form action="index.php" method="post">
            <table border="0">
            	<tr>
                	<td><input type="text" class="text" value="<?php echo $candidateObj->EMAIL;?>" name="mails" /></td>
                    <td></td>
                </tr>
                <tr>
                	<td colspan="2" align="right"> <input type="submit" value="Save" /></td>
                </tr>
            </table>
            </form>
            </center>
           
             
        </div>
        <div id="overlayEffect">
        </div>
       <!--end popup content--> 
        <input type="hidden" name="row_id" id="row_id" value="<?php echo JRequest::getVar('id');?>" />		

